from framwork.common.tools  import open_browsers
from time import sleep
from selenium.webdriver.common.by import By

"""添加客户关怀 ok"""
#数据
url=r"http://192.168.1.36/crm/index.php?m=user&a=login"
user_name="admin"
passwd="123456"
ghzt="中秋快乐"
ghrq="2025-08-28"
#定位器
username_locator=(By.NAME,"name")
password_locator=(By.NAME,"password")
login_btn_locator=(By.NAME,"submit")
customer_locator=(By.LINK_TEXT,"客户")
customer_gh_locator=(By.CSS_SELECTOR,"body > div.container > div.page-header > ul > li:nth-child(4) > a")

select_gh_locator=(By.CSS_SELECTOR,"body > div.container > div.row > div:nth-child(1) > div > a")
select_ghdj_locator=(By.CSS_SELECTOR,"#customer_name")
ok_locator=(By.CSS_SELECTOR,"body > div:nth-child(9) > div.ui-dialog-buttonpane.ui-widget-content.ui-helper-clearfix > div > button:nth-child(1)") #ok按钮
ghzt_locator=(By.CSS_SELECTOR,"#name")  #关怀主题
ghrq_locator=(By.CSS_SELECTOR,"#care_time")
save_locator=(By.NAME,"submit")
#操作
driver=open_browsers()
driver.get(url)
sleep(3)
driver.find_element(*username_locator).send_keys(user_name)
sleep(1)
driver.find_element(*password_locator).send_keys(passwd)
sleep(1)
driver.find_element(*login_btn_locator).click()
sleep(1)
driver.find_element(*customer_locator).click()
sleep(1)
driver.find_element(*customer_gh_locator).click()
sleep(1)
driver.find_element(*select_gh_locator).click()
sleep(1)
driver.find_element(*select_ghdj_locator).click()
sleep(1)
driver.find_element(*ok_locator).click()
sleep(1)
driver.find_element(*ghzt_locator).send_keys(ghzt)
sleep(1)
driver.find_element(*ghrq_locator).send_keys(ghrq)
sleep(1)
driver.find_element(*save_locator).click()
sleep(1)
#退出浏览器
sleep(3)
driver.close()